import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/getParameter")
public class GetParameter extends HelloServlet{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //此处约定，请求中给定的query String 是形如:username=zhangsan&password=123
        //上述query string，就会被自动解析成一个Map这样的结构
        //getParameter就是在查询Map<String,String> 里面的内容
        String username = req.getParameter("username");
        String password = req.getParameter("password");

        //就可以在拿到这俩的内容之后，做任意的处理
        System.out.println("username=" + username);
        System.out.println("password=" + password);
        resp.getWriter().write("ok");
    }
}

